function Trig_ResearchCostSystem_Actions takes nothing returns nothing
	local unit researcher = GetTriggerUnit()
	local player owner = GetOwningPlayer(researcher)
	local integer techType = GetResearched()
	local integer level = GetPlayerTechCount(owner , techType , true)
	local integer cost = LoadInteger(udg_CostTable , techType , level + 1)
	local integer goldOfOwner = GetPlayerState(owner , PLAYER_STATE_RESOURCE_GOLD)
	//--
	if goldOfOwner >= cost then
		call SetPlayerState(owner , PLAYER_STATE_RESOURCE_GOLD , goldOfOwner - cost)
	else
		call IssueImmediateOrderById(researcher , 0xD0008)
		call DisplayTimedTextToPlayer(owner , 0 , 0 , 2.0 , "黃金不足")
	endif
	//--
	set researcher = null
	set owner = null
endfunction

function InitTrig_ResearchCostSystem takes nothing returns nothing
    set gg_trg_ResearchCostSystem = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_ResearchCostSystem , EVENT_PLAYER_UNIT_RESEARCH_START)
    call TriggerAddAction(gg_trg_ResearchCostSystem , function Trig_ResearchCostSystem_Actions)
endfunction